app.controller('BusShiftPriceModalCtrl', function ($scope,$modal, $modalInstance, param,ajax) {

	$scope.param = param;
	if ($scope.param.data == null) {
		$scope.param.data = {};
	}

    //获取站点列表
    $scope.loadStationList = function () {
        var promise = ajax.call(new Req.GET({
            resource: 'shift/bs/station/'+$scope.param.data.id+'/list'
        }));
        promise.then(function (result) {
            $scope.list = result.result;
        }, function () { });
    };
    $scope.loadStationList();
	

    var updater = new Req.PUT({ resource: $scope.resource });
    
    $scope.write = function(size, current_data, submit_type) {
        $scope.current_data = angular.copy(current_data);
        var modalInstance = $modal.open({
            templateUrl: 'template/bus/shift/price.html?v=de24c3d905',
            controller: 'BusShiftPriceUpdateModalCtrl',
            size: size,
            resolve: {
                param: function() {
                    return {
                        "data": $scope.current_data,
                        "type": submit_type
                    };
                }
            }
        });

        modalInstance.result.then(function(param) {
            if (param.type == 'update') {
            	$scope.loadStationList();
                $modalInstance.close(param);
            }
        });
    };
    
	$scope.cancel = function () {
		$modalInstance.dismiss('cancel');
	};
});